// src/api/users.js
import request from '@/utils/request'

/**
 * 分页查询用户
 * GET /api/admin/users?pageNum=&pageSize=&username=
 */
export function pageUsers(params) {
    return request.get('/admin/users', { params })
}

/**
 * 获取用户详情
 * GET /api/admin/users/{id}
 */
export function getUser(id) {
    return request.get(`/admin/users/${id}`)
}

/**
 * 创建用户
 * POST /api/admin/users
 */
export function createUser(data) {
    return request.post('/admin/users', data)
}

/**
 * 更新用户
 * PUT /api/admin/users/{id}
 */
export function updateUser(id, data) {
    return request.put(`/admin/users/${id}`, data)
}

/**
 * 单个或批量删除用户
 * DELETE /api/admin/users?ids=1,2,3
 */
export function deleteUsers(ids) {
    // ids: Array<number>
    return request.delete('/admin/users', {
        params: { ids }
    })
}
